#include "CaseMainWindow.qth"
#include "CaseMainWindow.moh"
#include "QtUI/ConfigurationCommands.qth"
#include "QtUI/ProjectCommands.qth"
#include "QtUI/PackageCommands.qth"
#include "QtUI/UICommandBase.qth"
#include "QtUI/ProjectTreeView.qth"
#include "QtUI/QtUIConfigurationCenter.hpp"
#include "Ctrl/ControlCenter.hpp"
#include <QtGui/QMdiArea>
#include <QtGui/QMenuBar>
#include <QtGui/QToolBar>
#include <QtGui/QDockWidget>
#include <QtGui/QUndoStack>

CaseMainWindow::CaseMainWindow( Ctrl::ControlCenter& ctrlCenter, QWidget* pParent)
	: QMainWindow( pParent)
{
	QMdiArea* pMdiArea = new QMdiArea( this);
	this->setCentralWidget( pMdiArea);

	QMenuBar* pMenuBar = new QMenuBar( this);
	this->setMenuBar( pMenuBar);

	QMenu* pProjectMenu = pMenuBar->addMenu( tr( "&Project", "Project menu name"));
	pProjectMenu->addAction( QtUI::ProjectCommands::getNewProjectCommand().boundAction());
	pProjectMenu->addAction( QtUI::ProjectCommands::getOpenProjectCommand().boundAction());
	pProjectMenu->addAction( QtUI::ProjectCommands::getSaveProjectCommand().boundAction());
	pProjectMenu->addAction( QtUI::ProjectCommands::getCloseProjectCommand().boundAction());
	pProjectMenu->addSeparator();
	pProjectMenu->addAction( QtUI::PackageCommands::getNewPackageCommand().boundAction());
	pProjectMenu->addSeparator();
	pProjectMenu->addAction( QtUI::PackageCommands::getNewRootRequirementCommand().boundAction());

	QMenu* pEditMenu = pMenuBar->addMenu( tr( "&Edit", "Edit menu name"));
	QAction* pUndoAction = pEditMenu->addAction( tr( "&Undo"));
	QAction* pRedoAction = pEditMenu->addAction( tr( "&Redo"));
	QUndoStack* pUndoStack = QtUI::QtUIConfigurationCenter::qtUIConfigCenter().undoStack();
	connect( pUndoAction, SIGNAL( triggered()), pUndoStack, SLOT( undo()));
	connect( pRedoAction, SIGNAL( triggered()), pUndoStack, SLOT( redo()));
	connect( pUndoStack, SIGNAL( canRedoChanged( bool)), pRedoAction, SLOT( setEnabled(bool)));
	connect( pUndoStack, SIGNAL( canUndoChanged( bool)), pUndoAction, SLOT( setEnabled(bool)));
	

	QMenu* pConfigMenu = pMenuBar->addMenu( tr( "&Configuration", "Configuration menu name"));
	pConfigMenu->addAction( QtUI::ConfigurationCommands::getManageConnectionsCommand().boundAction());

	pProjectTreeView_ = new QtUI::ProjectTreeView( ctrlCenter);
	QDockWidget* pPrjTreeDock = new QDockWidget( tr( "Project", "Project Tree View Dock Title"));
	pPrjTreeDock->setWidget( pProjectTreeView_);
	this->addDockWidget( Qt::RightDockWidgetArea, pPrjTreeDock);
}

// ---------------------------------------------------------------------------------------------------------------------
void CaseMainWindow::show()
{
	this->QMainWindow::show();
}
